package net.steam.easyjoboa.biz.impl;

import java.util.ArrayList;
import java.util.List;

import net.steam.easyjoboa.biz.LoginLogBiz;
import net.steam.easyjoboa.dao.LoginLogDao;
import net.steam.easyjoboa.entity.LoginLog;
import net.steam.easyjoboa.entity.PageBean;

public class LoginLogBizImpl implements LoginLogBiz{

	/**
	 * 分页查找所有的记录
	 */
	private LoginLogDao loginLogDao;
	public List<LoginLog> findAllLog(PageBean pb,String star_time,String end_time) {
		List<Object> params=new ArrayList<Object>();
		String hql="from LoginLog l where 1=1";
		if(pb==null){
			pb=new PageBean();
		}
		if(star_time!=null&&star_time!=""){
			hql+=" and to_char(l.loginTime,'yyyy-MM-dd') between ? and ?";
			params.add(star_time);
			params.add(end_time);
		}
		hql+=" order by l.loginTime desc";
		pb.setPageSize(10);
		List<LoginLog> list=loginLogDao.find(pb, hql,params.toArray());
		return list;
	}
	
	/**
	 * 记录登录日志
	 */
	public void addLog(LoginLog log) {
		try {
			loginLogDao.addEntity(log);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public void setLoginLogDao(LoginLogDao loginLogDao) {
		this.loginLogDao = loginLogDao;
	}
	
}
